package lib

func init() {
	Probs = append(Probs, Problem{
		Num:         191,
		Discription: "二进制表示中1的个数",
		Level:       1,
		Labels: map[string]int{
			"位运算": 1,
		},
	})
}

func HammingWeight(n int) int {
	count := 0
	for n != 0 {
		last := n & 1
		count += last
		n >>= 1
	}

	return count
}

func HammingWeight2(n int) int {
	count:=0
    for n!=0{
        n&=n-1
        count++
    }

    return count
}